<!--
* @description:新增线路
* @fileName: TheNewLine
* @author:李周蓬
* @date:2021-1-
* @后台人员:李周蓬
-->
<template>
  <div>
    <table>
      <tr>
        <td>线路名称：</td>
        <td>
          <el-input
            v-model="AddData.LineName"
            placeholder="请输入内容"
          ></el-input>
        </td>
      </tr>
      <tr>
        <td>起点：</td>
        <td>
          <el-input
            v-model="AddData.BeginAddr"
            placeholder="请输入内容"
          ></el-input>
        </td>
      </tr>
      <tr>
        <td>终点：</td>
        <td>
          <el-input
            v-model="AddData.EndAddr"
            placeholder="请输入内容"
          ></el-input>
        </td>
      </tr>
      <tr>
        <td>是否外协：</td>
        <td>
         <el-select v-model="AddData.IsOutsource" placeholder="请选择">
            <el-option label="是" value="0"> 是</el-option>
            <el-option label="否" value="1"> 否</el-option>
          </el-select>
        </td>
      </tr>
      <tr>
        <td>货主：</td>
        <td>
          <el-select v-model="AddData.OwnerId" placeholder="请选择">
            <el-option
              v-for="item in bindData"
              :key="item.value"
              :label="item.OwnerName"
              :value="item.Id"
            >
            </el-option>
          </el-select>
        </td>
      </tr>
      <tr>
        <td>备注：</td>
        <td>
          <el-input type="textarea" v-model="AddData.Remark"></el-input>
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <el-button type="primary" @click="add">提交</el-button>
          <el-button @click="go">取消</el-button>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      AddData: {
        LineNumber: "",
        LineName: "",
        BeginAddr: "",
        EndAddr: "",
        IsOutsource: "",
        Remark: "",
        OwnerId: "",
      },
      bindData: [],
    };
  },
  methods: {
    add() {
      this.$axios
        .post("https://localhost:44399/api/app/line-app/add-line", this.AddData)
        .then((res) => {
          if (res.data > 0) {
            this.$message({
              type: "success",
              message: "添加成功!",
            });
            this.$router.push("/LineManagement");
          } else {
            this.$message({
              type: "error",
              message: "添加失败!",
            });
          }
        });
    },
    bind() {
      this.$axios
        .get("https://localhost:44399/api/app/line-app/bind")
        .then((res) => {
          this.bindData = res.data.PageData;
          this.bindData.unshift({ Id: 0, OwnerName: "请选择" });
        });
    },
    go() {
      this.$router.go(-1);
    },
  },
  created() {
    this.bind();
  },
};
</script>

<style>
</style>